package com.ymatou.iapi.trading.operate.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.enums.CancelOrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.req.BatchCancelOrderBean;
import com.ymatou.iapi.trading.operate.service.BatchCancelOrderCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.PaymentProxyCallService;
import com.ymttest.database.model.YmtCouponPrivateUserBound;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtCouponPrivateUserBoundWapper;
import com.ymttest.utils.constant.ECode;

/**
 * 批量取消订单 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_BatchCancelOrder {

	private static BatchCancelOrderBean batchcancelorderbean;
	private static BatchCancelOrderCall batchcancelordercall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量取消订单");
	}

	@Before
	public void caseUp() {

		batchcancelorderbean = new BatchCancelOrderBean();
		batchcancelordercall = new BatchCancelOrderCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(batchcancelordercall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_001() {
		Logger.start(true, "订单支付前,卖家批量取消订单成功，订单状态为12 买家取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int sellerId = 0;
			int userId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();
				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			Logger.verifyEquals(ECode.SUCCESS, batchcancelordercall.getCode(),
					"验证Code");
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);

				Logger.verifyEquals(12, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_002() {
		Logger.start(true, "订单支付前,买家批量取消订单成功,订单状态为13 卖家取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();
				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				int userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			Logger.verifyEquals(ECode.SUCCESS, batchcancelordercall.getCode(),
					"验证Code");
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(12, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_003() {
		Logger.start(true, "订单支付前,超时未支付批量系统自动取消订单,订单状态为18 系统自动取消");
		try {
			DefaultWapper database = new DefaultWapper();
			// 参数
			Logger.comment("前置数据准备");
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int sellerId = 0;
			int userId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();
				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				// 修改订单自动取消时间为0
				database.updateOrderAutoCancelOrderHoursByOrderId(0.00, orderId);

				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.SYSTEM_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(18, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 18).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_004() {
		Logger.start(true, "订单支付前,客服批量取消订单成功，订单状态为18 系统取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int sellerId = 0;
			int userId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();
				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.CUSTOMER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(18, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 18).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_005() {
		Logger.start(true, "订单卖家已接单,,客服批量取消订单成功，订单状态为18 系统取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额

				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				// 接单
				orderService.acceptOrder(orderId, sellerId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.CUSTOMER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(18, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 18).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_006() {
		Logger.start(true, "订单已支付商家未接单,风控批量取消订单成功，订单状态为18 系统自动取消");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.RISKCONTROL_CANCEL_ORDER
							.getCode()); // 卖家ID
			batchcancelorderbean.setUserId(userId); // 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = OrderIdList.get(i);
				Logger.verifyEquals(18, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 18).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_007() {
		Logger.start(true, "订单已支付商家未接单,买家批量取消订单成功，订单状态为12 买家取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(12, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_008() {
		Logger.start(true, "订单已支付商家未接单,卖家批量取消订单成功，订单状态为13 卖家取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.SELLER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(13, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 13).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_009() {
		Logger.start(true, "订单已支付商家未接单,客服批量取消订单成功，订单状态为18 系统取消订单");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.CUSTOMER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (int i = 0; i < size; i++) {
				Integer orderId = batchcancelorderbean.getOrderIdList().get(i);
				Logger.verifyEquals(18, database.getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						database.selectOrderTradingStatusByOrderIdAndTradingStatus(
								orderId, 18).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, database
						.selectOrderReasonByOrderIdAndUserId(orderId, userId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(orderId, batchcancelordercall
						.getCancelOrderResultList().get(i).getOrderId(),
						"验证订单OrderId");
				Logger.verifyEquals(true, batchcancelordercall
						.getCancelOrderResultList().get(i).getIsSuccess(),
						"验证订单取消状态");
				Logger.verifyEquals("", batchcancelordercall
						.getCancelOrderResultList().get(i).getResultInfo(),
						"验证ResultInfo");
				Logger.verifyEquals(null, batchcancelordercall
						.getCancelOrderResultList().get(i)
						.getThirdPartyRefundMessage(),
						"验证ThirdPartyRefundMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_010() {
		Logger.start(true, "订单在退货退款中,批量取消订单失败");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				// 退货退款同步
				orderService.applySalesRefundRequestInJava(orderId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.CUSTOMER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			Logger.verifyEquals(ECode.FAILED201,
					batchcancelordercall.getString("code"), "验证Code");
			Logger.verifyEquals("哈尼，"
					+ batchcancelorderbean.getOrderIdList().get(0)
					+ "此单有退货/退款，请先去处理~", batchcancelordercall.getMsg(), "验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_011() {
		Logger.start(true, "订单支付前,重复批量取消订单成功");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.CUSTOMER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			Logger.comment("重复批量取消");
			batchcancelordercall.callService();
			// 验证数据库
			Logger.verifyEquals(ECode.FAILED201,
					batchcancelordercall.getString("code"), "验证Code");
			Logger.verifyEquals(batchcancelorderbean.getOrderIdList().get(0)
					+ "此订单已取消~", batchcancelordercall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_012() {
		Logger.start(true, "订单号不存在,批量取消订单失败");
		try {
			// 参数
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 1113, sellerId = 3383;
			OrderIdList.add(111);
			OrderIdList.add(111);
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.CUSTOMER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			Logger.comment("重复批量取消");
			batchcancelordercall.callService();
			// 验证数据库
			Logger.verifyEquals(ECode.FAILED201,
					batchcancelordercall.getString("code"), "验证Code");
			Logger.verifyEquals("订单号不存在:"
					+ batchcancelorderbean.getOrderIdList().get(0),
					batchcancelordercall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_013() {
		Logger.start(true, "商家已接单,买家批量取消订单失败");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				// 接单
				orderService.acceptOrder(orderId, sellerId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(userId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			Logger.verifyEquals(ECode.FAILED201,
					batchcancelordercall.getString("code"), "验证Code");
			Logger.verifyEquals("哈尼，你的订单"
					+ batchcancelorderbean.getOrderIdList().get(0)
					+ "，买手刚刚接单了，只能走退货退款流程了哦~", batchcancelordercall.getMsg(),
					"验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_014() {
		Logger.start(true, "用户不是订单所有者,买家批量取消订单失败");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int userId = 0, sellerId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = new OrderCallService()
						.createM2cOrder();

				Integer orderId = placeOrderResp.getOrderList().get(0)
						.getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额
				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(1234);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();

			Logger.verifyEquals(ECode.FAILED201,
					batchcancelordercall.getString("code"), "验证Code");
			Logger.verifyEquals("用户" + batchcancelorderbean.getUserId()
					+ "不是订单" + OrderIdList.get(0) + "的所有者",
					batchcancelordercall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_015() {
		Logger.start(true, "同时使用平台,商家优惠券，支付前接单前,批量取消订单,退回优惠券");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			int sellerId = 0;
			int userId = 0;
			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();
				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();
				OrderIdList.add(orderId);
			}
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);
				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				List<YmtCouponPrivateUserBound> listCoupon1 = ymtCoupon
						.selectBysCouponCode(ymtCouponCode);
				List<YmtCouponPrivateUserBound> listCoupon2 = ymtCoupon
						.selectBysCouponCode(sellerCouponCode);

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(1,
						listCoupon1.get(0).getiCouponUsedCount(),
						"验证ymt平台优惠券退回");
				Logger.verifyEquals(1,
						listCoupon2.get(0).getiCouponUsedCount(), "验证商家优惠券退回");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_016() {
		Logger.start(true, "同时使用平台,商家优惠券，支付后接单前,批量取消订单,退回优惠券");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();

			int sellerId = 0;
			int userId = 0;

			// 创建订单
			for (int i = 0; i < 2; i++) {
				PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();
				int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
				sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
				userId = placeOrderResp.getUserId();
				int tradingId = placeOrderResp.getTradingId();

				BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额

				// 买家付款
				orderService.orderPayRequest(userId, totalPrice, tradingId);

				OrderIdList.add(orderId);
			}

			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();

			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();

			int size = OrderIdList.size();

			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);

				Thread.sleep(1000);

				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);

				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());

				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);

				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				List<YmtCouponPrivateUserBound> listCoupon1 = ymtCoupon
						.selectBysCouponCode(ymtCouponCode);

				List<YmtCouponPrivateUserBound> listCoupon2 = ymtCoupon
						.selectBysCouponCode(sellerCouponCode);

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(1,
						listCoupon1.get(0).getiCouponUsedCount(),
						"验证ymt平台优惠券退回");

				Logger.verifyEquals(1,
						listCoupon2.get(0).getiCouponUsedCount(), "验证商家优惠券退回");

				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_017() {
		Logger.start(true, "已付款状态:同一主单号下1个商家的多个订单,订单全部取消,退回商家券,退回平台优惠券");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orderList = placeOrderResp.getOrderList();

			orderList.forEach(o -> OrderIdList.add(o.getOrderId()));

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalPrice = placeOrderResp.getPayAmount();// 支付金额

			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);

			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);
				// 付款金额
				BigDecimal totalPrice1 = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				List<YmtCouponPrivateUserBound> listCoupon1 = ymtCoupon
						.selectBysCouponCode(ymtCouponCode);
				List<YmtCouponPrivateUserBound> listCoupon2 = ymtCoupon
						.selectBysCouponCode(sellerCouponCode);

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(1,
						listCoupon1.get(0).getiCouponUsedCount(),
						"验证ymt平台优惠券不退回");
				Logger.verifyEquals(1,
						listCoupon2.get(0).getiCouponUsedCount(), "验证商家优惠券退回");

				Logger.verifyEquals(totalPrice1, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_018() {
		Logger.start(true, "已付款状态:同一主单号下1个商家的多个订单,子订单没有全取消,不退回商家券,不退回平台优惠券");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额

			OrderIdList.add(placeOrderResp.getOrderList().get(0).getOrderId());

			// 买家付款
			orderService.orderPayRequest(userId, totalAmount, tradingId);
			Logger.comment("前置数据准备结束");

			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();

			int size = OrderIdList.size();

			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);
				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				List<YmtCouponPrivateUserBound> listCoupon1 = ymtCoupon
						.selectBysCouponCode(ymtCouponCode);
				List<YmtCouponPrivateUserBound> listCoupon2 = ymtCoupon
						.selectBysCouponCode(sellerCouponCode);

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(0,
						listCoupon1.get(0).getiCouponUsedCount(),
						"验证ymt平台优惠券不退回");
				Logger.verifyEquals(0,
						listCoupon2.get(0).getiCouponUsedCount(), "验证商家优惠券退回");

				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_019() {
		Logger.start(true, "一笔交易生成多个订单,(用户余额+第三方组合支付)，批量取消其中几单。"
				+ "校验退款余额和第三方支付的原路返回");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额

			List<Order> orderList = placeOrderResp.getOrderList();

			OrderIdList.add(placeOrderResp.getOrderList().get(0).getOrderId());

			BigDecimal blanceAmout = new BigDecimal(12);
			// 13 为 app国际支付宝，15 微信
			String payTpye = "13";
			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					blanceAmout, tradingId, payTpye);

			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);

			// 等待回调异步处理完成
			Thread.sleep(10000);
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 支付网关退款回调交易
			PaymentProxyCallService.refundNotifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 等待回调异步处理完成
			Thread.sleep(10000);
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单资金表
				List<Map> ymtOrderStateList = database
						.selectOrderStateByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);

				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());

				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				List<YmtCouponPrivateUserBound> listCoupon1 = ymtCoupon
						.selectBysCouponCode(ymtCouponCode);
				List<YmtCouponPrivateUserBound> listCoupon2 = ymtCoupon
						.selectBysCouponCode(sellerCouponCode);

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(0,
						listCoupon1.get(0).getiCouponUsedCount(),
						"验证ymt平台优惠券不退回");
				Logger.verifyEquals(0,
						listCoupon2.get(0).getiCouponUsedCount(), "验证商家优惠券退回");

				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfYmtAccount"),
						(BigDecimal) settlementList.get(0)
								.get("fAccountAmount"), "验证fAccountAmount");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfThirdParty"),
						(BigDecimal) settlementList.get(0).get(
								"fThirdPartyAmount"), "验证fThirdPartyAmount");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_020() {
		Logger.start(true, "一笔交易生成多个订单,(用户余额+支付宝组合支付)，批量取消所有子单,"
				+ "校验退款余额和第三方支付的原路返回");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			List<Order> orderList = placeOrderResp.getOrderList();

			orderList.forEach(o -> OrderIdList.add(o.getOrderId()));

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额

			BigDecimal blanceAmout = new BigDecimal(12);
			// 13 为 app国际支付宝，15 微信
			String payTpye = "13";
			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					blanceAmout, tradingId, payTpye);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 等待回调异步处理完成
			Thread.sleep(10000);
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 支付网关退款回调交易
			PaymentProxyCallService.refundNotifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 等待回调异步处理完成
			Thread.sleep(10000);
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单资金表
				List<Map> ymtOrderStateList = database
						.selectOrderStateByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);

				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());
				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");

				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfYmtAccount"),
						(BigDecimal) settlementList.get(0)
								.get("fAccountAmount"), "验证fAccountAmount");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfThirdParty"),
						(BigDecimal) settlementList.get(0).get(
								"fThirdPartyAmount"), "验证fThirdPartyAmount");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_021() {
		Logger.start(true, "一笔交易生成多个订单,(用户余额+微信组合支付)，批量取消所有子单,校验退款余额和"
				+ "第三方支付的原路返回");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			List<Order> orderList = placeOrderResp.getOrderList();

			orderList.forEach(o -> OrderIdList.add(o.getOrderId()));

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额

			BigDecimal blanceAmout = new BigDecimal(12);
			// 13 为 app国际支付宝，15 微信
			String payTpye = "15";
			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					blanceAmout, tradingId, payTpye);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 等待回调异步处理完成
			Thread.sleep(10000);
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 支付网关退款回调交易
			PaymentProxyCallService.refundNotifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);

			// 等待回调异步处理完成
			Thread.sleep(10000);
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单资金表
				List<Map> ymtOrderStateList = database
						.selectOrderStateByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);

				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());
				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");

				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfYmtAccount"),
						(BigDecimal) settlementList.get(0)
								.get("fAccountAmount"), "验证fAccountAmount");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfThirdParty"),
						(BigDecimal) settlementList.get(0).get(
								"fThirdPartyAmount"), "验证fThirdPartyAmount");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_022() {
		Logger.start(true, "一笔交易生成多个订单,(第三方全款支付)，批量取消所有子单,校验退款余额和第三方支付的原路返回");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			List<Order> orderList = placeOrderResp.getOrderList();

			orderList.forEach(o -> OrderIdList.add(o.getOrderId()));

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额
			BigDecimal blanceAmout = BigDecimal.ZERO;
			// 13 为 app国际支付宝，15 微信
			String payTpye = "13";
			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					blanceAmout, tradingId, payTpye);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);

			// 等待回调异步处理完成
			Thread.sleep(10000);
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 支付网关退款回调交易
			PaymentProxyCallService.refundNotifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 等待回调异步处理完成
			Thread.sleep(10000);
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单资金表
				List<Map> ymtOrderStateList = database
						.selectOrderStateByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);

				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());

				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfYmtAccount"),
						(BigDecimal) settlementList.get(0)
								.get("fAccountAmount"), "验证fAccountAmount");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfThirdParty"),
						(BigDecimal) settlementList.get(0).get(
								"fThirdPartyAmount"), "验证fThirdPartyAmount");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");

				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fRefundedAmountOfCash"),
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfCash"), "验证fRefundedAmountOfCash");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_023() {
		Logger.start(true, "一笔交易生成多个订单,(全款余额支付)，批量取消所有子单,校验退款余额和第三方支付的原路返回");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();
			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			List<Order> orderList = placeOrderResp.getOrderList();

			orderList.forEach(o -> OrderIdList.add(o.getOrderId()));

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额
			BigDecimal blanceAmout = totalAmount;

			// 13 为 app国际支付宝，15 微信
			String payTpye = "13";
			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					blanceAmout, tradingId, payTpye);
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);

				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());

				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_BatchCancelOrder_024() {
		Logger.start(true, "余额+第三方组合支付,批量取消不是一个交易号下的子单,校验退款余额和第三方支付的原路返回");
		try {
			// 参数
			Logger.comment("前置数据准备");
			OrderCallService orderService = new OrderCallService();
			ArrayList<Integer> OrderIdList = new ArrayList<Integer>();

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			int orderId1 = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalAmount = placeOrderResp.getPayAmount();// 支付金额

			PlaceOrderResp placeOrderResp2 = PlaceOrderService.placeOrder3();

			// 第二笔交易
			int orderId2 = placeOrderResp2.getOrderList().get(0).getOrderId();
			int tradingId2 = placeOrderResp2.getTradingId();

			BigDecimal totalAmount2 = placeOrderResp2.getPayAmount();// 支付金额

			OrderIdList.add(orderId1);
			OrderIdList.add(orderId2);

			// 支付第一笔交易
			BigDecimal blanceAmout = new BigDecimal(12);
			// 13 为 app国际支付宝，15 微信
			String payTpye = "13";
			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					blanceAmout, tradingId, payTpye);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 支付第二笔交易
			BigDecimal blanceAmout2 = new BigDecimal(18);
			// 13 为 app国际支付宝，15 微信
			String payTpye2 = "15";
			int thirdTradingId2 = new OrderCallService().orderPayRequest(
					userId, blanceAmout2, tradingId2, payTpye2);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payTpye2,
					String.valueOf(thirdTradingId2),
					totalAmount2.subtract(blanceAmout2).toString(), userId);
			// 等待回调异步处理完成
			Thread.sleep(10000);
			Logger.comment("前置数据准备结束");
			batchcancelorderbean.setOrderIdList(OrderIdList);
			batchcancelorderbean.setCancelReason("自动化测试取消订单");
			batchcancelorderbean
					.setCancelType(CancelOrderTypeEnum.BUYER_CANCEL_ORDER
							.getCode());
			// 卖家ID
			batchcancelorderbean.setUserId(sellerId);
			// 发送请求
			batchcancelordercall.setData(batchcancelorderbean);
			batchcancelordercall.callService();

			// 支付网关退款回调交易
			PaymentProxyCallService.refundNotifyCall(payTpye,
					String.valueOf(thirdTradingId),
					totalAmount.subtract(blanceAmout).toString(), userId);
			// 支付网关退款回调交易
			PaymentProxyCallService.refundNotifyCall(payTpye2,
					String.valueOf(thirdTradingId2),
					totalAmount2.subtract(blanceAmout2).toString(), userId);

			// 等待回调异步处理完成
			// Thread.sleep(10000);
			// 验证数据库
			DefaultWapper database = new DefaultWapper();
			// 数据库验证
			YmtCouponPrivateUserBoundWapper ymtCoupon = new YmtCouponPrivateUserBoundWapper();
			int size = OrderIdList.size();
			for (Integer orderId : OrderIdList) {
				// 订单主表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单资金表
				List<Map> ymtOrderStateList = database
						.selectOrderStateByOderId(orderId);
				// 订单结算
				List<Map> settlementList = database
						.selectYmtSettlementInvoice(orderId);
				settlementList = settlementList.stream()
						.filter(m -> (Integer) m.get("BusinessType") == 3)
						.collect(Collectors.toList());

				// 付款金额
				BigDecimal totalPrice = orderService
						.getNeedPrePayAmountOfCash(orderId);
				// 平台券
				String ymtCouponCode = (String) ymtOrders.get(0).get(
						"sYmtCouponCode");
				// 商家券
				String sellerCouponCode = (String) ymtOrders.get(0).get(
						"sSellerCouponCode");

				Logger.verifyEquals(12,
						new DefaultWapper().getTradingStatus(orderId),
						"验证订单交易状态");
				Logger.verifyEquals(
						1,
						new DefaultWapper()
								.selectOrderTradingStatusByOrderIdAndTradingStatus(
										orderId, 12).size(),
						"验证TradingStatus表中 增加一条订单操作记录");
				Logger.verifyEquals(1, new DefaultWapper()
						.selectOrderReasonByOrderIdAndUserId(orderId, sellerId)
						.size(), "验证Ymt_OrderReason表中增加一条订单取消原因记录");
				Logger.verifyEquals(totalPrice, (BigDecimal) settlementList
						.get(0).get("CashAmount"), "验证退款金额是否等于付款金额");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementUser"),
						"验证SettlementUser 为1");
				Logger.verifyEquals(1,
						settlementList.get(0).get("SettlementStatus"),
						"验证SettlementStatus 为1");

				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfYmtAccount"),
						(BigDecimal) settlementList.get(0)
								.get("fAccountAmount"), "验证fAccountAmount");
				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfThirdParty"),
						(BigDecimal) settlementList.get(0).get(
								"fThirdPartyAmount"), "验证fThirdPartyAmount");
				Logger.verifyEquals(3, settlementList.get(0)
						.get("BusinessType"), "验证BusinessType 为3");
				Logger.verifyEquals(
						(BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount"),
						(BigDecimal) settlementList.get(0).get("CouponAmount"),
						"验证退款结算单退回的平台CouponAmount");

				Logger.verifyEquals(
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fRefundedAmountOfCash"),
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfCash"), "验证fRefundedAmountOfCash");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}
